package conf

import (
	"path"
	"generalhandler/utils"
	"fmt"
)

type HandlerConfig struct {
	ScanType string `json:"scan_type"`
	InputKeys string `json:"input_keys"`
	ReplaceVars string `json:"replace_vars"`
	ProxychainsBin string `json:"proxychains_bin"`
	ProxychainsConf string `json:"proxychains_conf"`
	CmdBin string `json:"cmd_bin"`
	CmdTimeout int `json:"cmd_timeout"`
	CmdArgs string `json:"cmd_args"`
	CmdOutfile string `json:"cmd_outfile"`
	OutputHandles []OutputHandle `json:"output_handles"`
}

type OutputHandle struct {
	OutputKey string `json:"output_key"`
	NewKey string `json:"new_key"`
	NextHandler []string `json:"next_handler"`
}

var hc *HandlerConfig
func HandlerConfigInstance() *HandlerConfig {
	return hc
}

func LoadHCConf() {
	path := path.Join(utils.GetSelfBinDirPath(), "hc.config")
	if err := utils.LoadJsonFromFile(path, &hc); nil != err {
		panic(fmt.Sprintf("failed to load hc config, cuz %s", err.Error()))
	}
}
